#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include <sys/socket.h>
#include "socklib.h"

void process_request(int fd);

int main()
{
    int sock_id = make_server_socket(1496);
    if (sock_id == -1){
        return -1;
    }
    while(1){
        int fd;
        fd = accept(sock_id,NULL,NULL);
        if (fd == -1){
            break;
        }
        process_request(fd);
        close(fd);
    }

    return 0;
}

void process_request(int fd)
{
    time_t now;
    char *cp;
    time(&now);
    cp = ctime(&now);
	//printf("%s\nlen: %d\n",cp,strlen(cp));
    write(fd,cp,strlen(cp));
}

